home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / app / CompositeManager.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  4.1 KB  |  218 lines

  1. package com.extensibility.app;
  2.  
  3. import com.extensibility.util.RuleSplitPane;
  4. import java.awt.Component;
  5. import java.awt.Container;
  6. import javax.swing.JComponent;
  7. import javax.swing.SwingUtilities;
  8. import javax.swing.border.Border;
  9.  
  10. public class CompositeManager {
  11.    RuleSplitPane botSplit;
  12.    RuleSplitPane leftSplit;
  13.    int botRule = 130;
  14.    int leftRule = 175;
  15.    Pane botPane;
  16.    Pane leftPane;
  17.    Pane mainPane;
  18.    Container container;
  19.    JComponent contentCenter;
  20.  
  21.    public CompositeManager(Container var1, Pane var2) {
  22.       this.container = var1;
  23.       this.mainPane = var2;
  24.       if (this.getMainPane() != null) {
  25.          this.addAsContentPaneCenter(this.getMainPane().getComponent());
  26.       }
  27.  
  28.    }
  29.  
  30.    public CompositeManager(Container var1, Pane var2, Pane var3, Pane var4) {
  31.       this.container = var1;
  32.       this.leftPane = var2;
  33.       this.mainPane = var3;
  34.       this.botPane = var4;
  35.       if (this.getMainPane() != null) {
  36.          this.addAsContentPaneCenter(this.getMainPane().getComponent());
  37.       }
  38.  
  39.    }
  40.  
  41.    public void addAsContentPaneCenter(JComponent var1) {
  42.       if (this.contentCenter != var1) {
  43.          if (this.contentCenter != null) {
  44.             this.container.remove(this.contentCenter);
  45.          }
  46.  
  47.          this.container.add(var1);
  48.          this.contentCenter = var1;
  49.       }
  50.    }
  51.  
  52.    public Pane getFocusedPane() {
  53.       Object var1 = null;
  54.  
  55.       for(Object var2 = SwingUtilities.findFocusOwner(this.container); var2 != null; var2 = ((Component)var2).getParent()) {
  56.          if (var2 == this.getMainComponent()) {
  57.             return this.getMainPane();
  58.          }
  59.  
  60.          if (var2 == this.getLeftComponent()) {
  61.             return this.getLeftPane();
  62.          }
  63.  
  64.          if (var2 == this.getBottomComponent()) {
  65.             return this.getBottomPane();
  66.          }
  67.       }
  68.  
  69.       return this.getMainPane();
  70.    }
  71.  
  72.    public boolean showHideBottomPane(boolean var1) {
  73.       if (var1 == this.isBotPaneVisible()) {
  74.          return true;
  75.       } else {
  76.          Object var2 = this.isLeftPaneVisible() ? this.leftSplit : this.getMainComponent();
  77.          if (var1) {
  78.             if (!this.getBottomPane().addRequest()) {
  79.                return false;
  80.             }
  81.  
  82.             this.botSplit = new RuleSplitPane(0, (Component)var2, this.getBottomComponent());
  83.             this.botSplit.setBorder((Border)null);
  84.             this.botSplit.setDividerRule(false, this.botRule);
  85.             this.addAsContentPaneCenter(this.botSplit);
  86.             this.container.validate();
  87.             this.botSplit.resetDividerLoc();
  88.          } else {
  89.             if (!this.getBottomPane().removeRequest()) {
  90.                return false;
  91.             }
  92.  
  93.             this.botRule = this.botSplit.getDividerRulePos();
  94.             this.botSplit = null;
  95.             this.addAsContentPaneCenter((JComponent)var2);
  96.             this.container.validate();
  97.          }
  98.  
  99.          return true;
  100.       }
  101.    }
  102.  
  103.    public boolean showHideLeftPane(boolean var1) {
  104.       if (var1 == this.isLeftPaneVisible()) {
  105.          return true;
  106.       } else if (var1 && !this.getLeftPane().addRequest()) {
  107.          return false;
  108.       } else if (!var1 && !this.getLeftPane().removeRequest()) {
  109.          return false;
  110.       } else {
  111.          if (this.isBotPaneVisible()) {
  112.             if (var1) {
  113.                this.leftSplit = new RuleSplitPane(1, this.getLeftComponent(), this.getMainComponent());
  114.                this.leftSplit.setBorder((Border)null);
  115.                this.leftSplit.setDividerRule(true, this.leftRule);
  116.                this.botSplit.setLeftComponent(this.leftSplit);
  117.             } else {
  118.                this.leftRule = this.leftSplit.getDividerRulePos();
  119.                this.leftSplit = null;
  120.                this.botSplit.setLeftComponent(this.getMainComponent());
  121.             }
  122.  
  123.             this.botSplit.resetDividerLoc();
  124.          } else if (var1) {
  125.             this.leftSplit = new RuleSplitPane(1, this.getLeftComponent(), this.getMainComponent());
  126.             this.leftSplit.setBorder((Border)null);
  127.             this.leftSplit.setDividerRule(true, this.leftRule);
  128.             this.addAsContentPaneCenter(this.leftSplit);
  129.             this.container.validate();
  130.             this.leftSplit.resetDividerLoc();
  131.          } else {
  132.             this.leftRule = this.leftSplit.getDividerRulePos();
  133.             this.leftSplit = null;
  134.             this.addAsContentPaneCenter(this.getMainComponent());
  135.             this.container.validate();
  136.          }
  137.  
  138.          return true;
  139.       }
  140.    }
  141.  
  142.    public boolean isBotPaneVisible() {
  143.       return this.botSplit != null;
  144.    }
  145.  
  146.    public boolean isLeftPaneVisible() {
  147.       return this.leftSplit != null;
  148.    }
  149.  
  150.    public Pane getBottomPane() {
  151.       return this.botPane;
  152.    }
  153.  
  154.    public JComponent getBottomComponent() {
  155.       return this.botPane == null ? null : this.botPane.getComponent();
  156.    }
  157.  
  158.    public Pane getLeftPane() {
  159.       return this.leftPane;
  160.    }
  161.  
  162.    public JComponent getLeftComponent() {
  163.       return this.leftPane == null ? null : this.leftPane.getComponent();
  164.    }
  165.  
  166.    public Pane getMainPane() {
  167.       return this.mainPane;
  168.    }
  169.  
  170.    public JComponent getMainComponent() {
  171.       return this.mainPane.getComponent();
  172.    }
  173.  
  174.    public boolean setMainPane(Pane var1) {
  175.       if (var1 == this.getMainPane()) {
  176.          return true;
  177.       } else if (this.getMainPane() != null && !this.getMainPane().removeRequest()) {
  178.          return false;
  179.       } else if (!var1.addRequest()) {
  180.          return false;
  181.       } else {
  182.          if (this.isLeftPaneVisible()) {
  183.             this.leftSplit.setRightComponent(var1.getComponent());
  184.             this.leftSplit.resetDividerLoc();
  185.          } else if (this.isBotPaneVisible()) {
  186.             this.botSplit.setLeftComponent(var1.getComponent());
  187.             this.botSplit.resetDividerLoc();
  188.          } else {
  189.             this.addAsContentPaneCenter(var1.getComponent());
  190.             this.container.validate();
  191.             var1.getComponent().repaint();
  192.          }
  193.  
  194.          this.mainPane = var1;
  195.          this.mainPane.requestFocus();
  196.          return true;
  197.       }
  198.    }
  199.  
  200.    public void setLeftPane(Pane var1) {
  201.       if (this.isLeftPaneVisible()) {
  202.          this.leftSplit.setLeftComponent(var1.getComponent());
  203.          this.leftSplit.resetDividerLoc();
  204.       }
  205.  
  206.       this.leftPane = var1;
  207.    }
  208.  
  209.    public void setBottomPane(Pane var1) {
  210.       if (this.isBotPaneVisible()) {
  211.          this.botSplit.setRightComponent(var1.getComponent());
  212.          this.botSplit.resetDividerLoc();
  213.       }
  214.  
  215.       this.botPane = var1;
  216.    }
  217. }
  218.